package com.example.lj.uav.enums;

import java.util.ArrayList;
import java.util.List;

public enum PayloadErr {
    A("工作正常", 0),
    B("控温失败", 1),
    C("激光器错误", 2),
    D("电路板温度超过-20~80℃", 4),
    E("激光器外壳温度超过-25~65℃", 8),
    F("参考通道错误", 16);

    private String name;
    private int index;

    PayloadErr(String name, int index) {
        this.name = name;
        this.index = index;
    }

    public static String getNameByIndex(int index) {
        for (PayloadErr a : PayloadErr.values()) {
            if (a.getIndex() == index) {
                return a.getName();
            }
        }
        return "未知错误";
    }

    public static List<String> getAll() {
        ArrayList<String> list = new ArrayList<>();
        for (PayloadErr m : PayloadErr.values()) {
            list.add(m.getName());
        }
        return list;
    }

    public String getName() {
        return name;
    }

    public int getIndex() {
        return index;
    }
}
